 <?PHP
session_start();
$uname=$_POST['txtuname'];
$password=md5($_POST['txtpassword']);

include'admin/logic/Classes/db.php';

$db=new DbConnect();
$con=$db->getConnection();
//checkin usename and password matching 
$result=mysql_query("select * from login Where u_name='$uname' and p_word='$password' and status='Active'");

$count=mysql_num_rows($result);
$time_now=mktime(date('H')+5,date('i')+30,date('s'),date('m'),date('d'),date('Y'));
$log=date('Y-m-d H:i:s',$time_now);

if($count==1){



$_SESSION['user']=$uname;

mysql_query("insert into history(u_name,log_date) values('$uname','$log')");
mysql_close($con);


while($row=mysql_fetch_array($result)){

$level=$row['level'];
}

if($level=="Admin"){

header("location:admin/admin/admin_home.php"); 

} 

if($level=="User"){

header("location:user/admin/admin_home.php"); 

} 

if($level=="Parent"){

header("location:parent/parent_home.php"); 

} 




}else

{

$msg="Username and Password are not matching";
header("location:index.php?tab=$msg"); 

}


?>